package com.astn.adapter.booking;

import java.util.ArrayList;

import com.astn.bks.R;
import com.astn.bks.util.DateUtils;
import com.astn.entity.booking.CRequestHolder;
import com.astn.entity.booking.MessageHolder;
import com.astn.entity.booking.QuoteMessage;
import com.astn.entity.booking.QuoteRequest;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MessageAdapter extends BaseAdapter {
	private Context context;

	private LayoutInflater mInflater;

	ArrayList<QuoteMessage> lstItems = new ArrayList<QuoteMessage>();

	public MessageAdapter(Context context, ArrayList<QuoteMessage> lstItems) {
		this.context = context;
		this.lstItems = lstItems;
		mInflater = LayoutInflater.from(this.context);
	}

	@Override
	public int getCount() {
		return lstItems.size();
	}

	@Override
	public QuoteMessage getItem(int position) {
		return lstItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return lstItems.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MessageHolder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.messageitem, null);
			holder = new MessageHolder();
			holder.txvFrom = (TextView) convertView.findViewById(R.id.txvFrom);
			holder.txvSendAt = (TextView) convertView
					.findViewById(R.id.txvSendAt);
			holder.txvTitle = (TextView) convertView
					.findViewById(R.id.txvTitle);
			convertView.setTag(holder);
		} else {
			holder = (MessageHolder) convertView.getTag();
		}
		holder.txvFrom.setText(lstItems.get(position).getFromname());
		holder.txvSendAt.setText(DateUtils.quoteDateFormat.format(lstItems.get(
				position).getSendat()));
		holder.txvTitle.setText(lstItems.get(position).getSubject());
		// holder.txvInfo.setText(lstItems.get(position).getCountryid());
		return convertView;
	}
}
